package hcn.protocol.ods.checkAppointment.xml;

import ctd.util.JSONUtils;
import ctd.util.xml.jaxb.JAXBUtils;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

/**
 * 检查项目的可预约日期查询XML出参
 *
 * @author neoLin - 2023/01/13 15:39
 */
@XmlRootElement(name = "Data")
public class QueryAppointDateXmlResponse {

    private Item item;

    @XmlElement(name = "Item")
    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    @XmlRootElement(name = "Item")
    public static class Item {

        /**
         * 检查申请单号
         */
        private String requestId;
        /**
         * 检查项目代码
         */
        private String itemCode;
        /**
         * 检查项目名称
         */
        private String itemName;

        private List<AppointDate> appointDates;

        @XmlElement(name = "RequestId")
        public String getRequestId() {
            return requestId;
        }

        public void setRequestId(String requestId) {
            this.requestId = requestId;
        }

        @XmlElement(name = "ItemCode")
        public String getItemCode() {
            return itemCode;
        }

        public void setItemCode(String itemCode) {
            this.itemCode = itemCode;
        }

        @XmlElement(name = "ItemName")
        public String getItemName() {
            return itemName;
        }

        public void setItemName(String itemName) {
            this.itemName = itemName;
        }

        @XmlElement(name = "Date")
        public List<AppointDate> getAppointDates() {
            return appointDates;
        }

        public void setAppointDates(List<AppointDate> appointDates) {
            this.appointDates = appointDates;
        }
    }

    @XmlRootElement(name = "Date")
    public static class AppointDate {
        /**
         * 预约队列
         */
        private String appointsQueue;
        /**
         * 预约日期yyyymmdd
         */
        private String appointsDate;
        /**
         * 预约名称
         */
        private String appointsQueueName;

        @XmlElement(name = "AppointsQueue")
        public String getAppointsQueue() {
            return appointsQueue;
        }

        public void setAppointsQueue(String appointsQueue) {
            this.appointsQueue = appointsQueue;
        }

        @XmlElement(name = "AppointsDate")
        public String getAppointsDate() {
            return appointsDate;
        }

        public void setAppointsDate(String appointsDate) {
            this.appointsDate = appointsDate;
        }

        @XmlElement(name = "AppointsQueueName")
        public String getAppointsQueueName() {
            return appointsQueueName;
        }

        public void setAppointsQueueName(String appointsQueueName) {
            this.appointsQueueName = appointsQueueName;
        }
    }

    public static void main(String[] args) {
        String resultXml = "<Data>\n" +
                "            <Item>\n" +
                "                <RequestId>120270822</RequestId>\n" +
                "                <ItemCode>115183</ItemCode>\n" +
                "                <ItemName>彩色B超(1部位)</ItemName>\n" +
                "                <Date>\n" +
                "                    <AppointsQueue>62</AppointsQueue>\n" +
                "                    <AppointsQueueName>超声(徐浩)</AppointsQueueName>\n" +
                "                    <AppointsDate>20230302</AppointsDate>\n" +
                "                </Date>\n" +
                "                <Date>\n" +
                "                    <AppointsQueue>62</AppointsQueue>\n" +
                "                    <AppointsQueueName>超声(徐浩)</AppointsQueueName>\n" +
                "                    <AppointsDate>20230303</AppointsDate>\n" +
                "                </Date>\n" +
                "                <Date>\n" +
                "                    <AppointsQueue>62</AppointsQueue>\n" +
                "                    <AppointsQueueName>超声(徐浩)</AppointsQueueName>\n" +
                "                    <AppointsDate>20230305</AppointsDate>\n" +
                "                </Date>\n" +
                "                <Date>\n" +
                "                    <AppointsQueue>62</AppointsQueue>\n" +
                "                    <AppointsQueueName>超声(徐浩)</AppointsQueueName>\n" +
                "                    <AppointsDate>20230306</AppointsDate>\n" +
                "                </Date>\n" +
                "            </Item>\n" +
                "        </Data>";
        QueryAppointDateXmlResponse response = JAXBUtils.xml2Object(resultXml, QueryAppointDateXmlResponse.class);
        System.out.println(JSONUtils.writeValueAsString(response));
    }
}
